﻿import com.gamemeal.mvc.IView;
import com.gamemeal.mvc.IModel;
import com.gamemeal.mvc.Binding;
/**
 * @author colin
 */
class com.gamemeal.mvc.AbstractView extends MovieClip implements IView {
	private var bindingCollection:Array;
	
	private function onLoad(){
		bindingCollection = new Array();
		bind();
	}
	
	public function refresh(evt):Void{
		//reflect model to view
		var objBinding:Binding;
		for(var i=0;i<bindingCollection.length;i++){
			objBinding = bindingCollection[i];
			objBinding.view.setValue(objBinding.bind.value);
		}
	};

	private function viewUpdatedBindMapUpdate(view:MovieClip):Number{
		//splice the current value
		//push the updated value to bindMap
		for(var i=0;i<bindingCollection.length;i++){
			if(bindingCollection[i].view===view)return bindingCollection.push(bindingCollection.splice(i,1)[0]);
		}
	}

	public function getValue(){
		return bindingCollection;
	}
	
	public function setValue(value : Object) : Void {
	}
	
	private function bind() : Void {}

}